import type { AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from "axios";

// 扩展 axios 请求配置
export interface RequestConfig extends AxiosRequestConfig {
    loading?: boolean;
    apiName?: string | null;
    is?: string;
    url?: string;
}

// 扩展内部请求配置（用于请求拦截器）
export interface InternalRequestConfig extends InternalAxiosRequestConfig {
    loading?: boolean;
    apiName?: string | null;
    is?: string;
    url?: string;
}

// 标准响应数据结构
export interface ResponseData<T = any> {
    code: number;
    data: T;
    msg?: string;
    message?: string;
}

// 请求拦截器类型
export type RequestInterceptor = (
    config: InternalRequestConfig
) => InternalRequestConfig | Promise<InternalRequestConfig>;

// 响应拦截器类型
export type ResponseInterceptor = (response: AxiosResponse<ResponseData>) => any | Promise<any>;

// 错误拦截器类型
export type ErrorInterceptor = (error: any) => any;
